package algorithms.leecode;

public class Au80 {

    public int removeDuplicates(int[] nums) {

        int ind = 0;
        int j = 0;
        int start = 0;
        for(int i = 0; i < nums.length; i++) {
            if (i - ind >= 2  && nums[i] == nums[ind]) {
                nums[i] = 100000;
                if (start == 0) {
                    start = i;
                }
                continue;
            }

            if (nums[i] != nums[ind]) {
                ind = i;
            }
            nums[start] = nums[i];
            start++;
            j++;
        }


        return j;
    }

    public static void main(String[] args) {
        new Au80().removeDuplicates(new int[]{0,0,0,0,0,0,0});
    }

    public void move(int[] nums) {
        int start = 0;
        for (int i = 0; i < nums.length; i++) {
            if (start == 0 && nums[i] == 100000) {
                start = i;
            }
            if (nums[i] != 100000) {
                nums[start] = nums[i];
                start++;
            }
        }
    }
}
